package com.xsd.Factory.simpleFactory.pizzastore.order;

import com.xsd.Factory.simpleFactory.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Description:
 * @Author: zhoufuzong
 * @Created: 2021-01-23 17:44:14
 * @Version: 1.1.0
 */

public class OrderPizza2 {

    Pizza pizza =null;

    String orderType ="";

    public OrderPizza2(){

        do {
            orderType =getType();
            pizza= SimpleFactory.creatPizza2(orderType);
            if (pizza!=null){
                pizza.prepare();;
                pizza.bake();
                pizza.cut();
                pizza.box();
            }else {
                System.out.println("订购披萨失败");
                break;
            }
        }while (true);
    }

    // 写一个方法，可以获取客户希望订购的披萨种类
    private String getType() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza 种类:");
            String s = strin.readLine();
            return s;
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
